#include<iostream>

using namespace std;

string s;
int kind;
int mp[26];
int main()
{
    cin >> s;
    int n = s.size();
    int ret = n;
    for(int left = 0 , right = 0;right < n;right++)
    {
        if(mp[s[right]] ++ == 0) kind++;
        //判断
        while(kind == 26)
        {
            ret = min(ret , right - left + 1);
            if(mp[s[left]]-- == 1) kind--;
            left ++;
        }
    }
    cout << ret << endl;
    return 0;
}